<?php
class Util_String
{
    /**
     * Constructor of class
     */
    public function  __construct()
    {
        
    }

    /**
     * Convert string
     */
    public static function convert($str)
    {
        $str    = mb_strtolower($str, 'UTF-8');
        $str	= preg_replace('/(à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ)/', 'a', $str);
        $str	= preg_replace('/(è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ)/', 'e', $str);
        $str	= preg_replace('/(ì|í|ị|ỉ|ĩ)/', 'i', $str);
        $str	= preg_replace('/(ò|ó|ọ|ỏ|õ|ô|ồ|ố|ộ|ổ|ỗ|ơ|ờ|ớ|ợ|ở|ỡ)/', 'o', $str);
        $str	= preg_replace('/(ù|ú|ụ|ủ|ũ|ư|ừ|ứ|ự|ử|ữ)/', 'u', $str);
        $str	= preg_replace('/(ỳ|ý|ỵ|ỷ|ỹ)/', 'y', $str);
        $str	= preg_replace('/(đ)/', 'd', $str);
        $str	= preg_replace('/[^a-z0-9]/', '-', $str);
        $str    = preg_replace('/(-)+/', '-', $str);
        return $str;
    }
}